package com.xxxx.server.controller;


import com.xxxx.server.pojo.Department;
import com.xxxx.server.service.IDepartmentService;
import com.xxxx.server.vo.RespBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 学海无涯
 * @since 2021-11-15
 */
@RestController
@RequestMapping("/system/basic/department")
@Api(tags = "部门管理")
public class DepartmentController {

    @Autowired
    private IDepartmentService departmentService;

    @ApiOperation("获取所有部门")
    @GetMapping("")
    public RespBean<List<Department>> getAllDepartment(){
        List<Department> departmentList = departmentService.getAllDepartment();
        return new RespBean<List<Department>>().success("ok",departmentList);
    }

    @ApiOperation("添加部门")
    @PostMapping("")
    public RespBean addDepartment(@RequestBody Department department){
        return departmentService.addDep(department);
    }

    @ApiOperation("删除部门")
    @DeleteMapping("/{id}")
    public RespBean removeDepartment(@PathVariable Integer id){
        return departmentService.delDepartment(id);
    }
}
